package Cantella::DJabberd::Store::Result::UserRole;

use base qw'DBIx::Class::Core';
use metaclass 'Reaction::Meta::Class';
use Moose;

use aliased 'Cantella::DJabberd::Store::Result::User';
use aliased 'Cantella::DJabberd::Store::Result::Role';

use namespace::clean -except => [ 'meta' ];

__PACKAGE__->table('user_roles');
__PACKAGE__->add_columns
  (
   user_id => {
                data_type => "INT",
                size => 10,
                is_nullable => 0,
                extra => { unsigned => 1 },
                is_foreign_key => 1,
               },
   role_id => {
                data_type => "INT",
                size => 10,
                is_nullable => 0,
                extra => { unsigned => 1 },
                is_foreign_key => 1,
               },
  );

__PACKAGE__->set_primary_key(qw/role_id user_id/);

__PACKAGE__->belongs_to(user => User, { id => "user_id" });
__PACKAGE__->belongs_to(role => Role, { id => "role_id" });

__PACKAGE__->meta->make_immutable(inline_constructor => 0);

1;
